package org.example.dyscript.dynamicscript;

import org.xidea.el.Expression;
import org.xidea.el.impl.ExpressionImpl;

import java.util.Map;

public class JselRule implements Rule {


  Expression executeExpression;
  Expression evaluateExpression;

  String executeScript = "ali_score > 100 "
      + "&& wx_score < 450 "
      + "&& !pd_living_province.contains(\"乌克兰\") "
      + "&& pd_census_province.contains(\"吉尔吉斯斯坦\")";

  String evaluateScript = "age > 18 && vip.contains(\"vip\")";

  public JselRule() {
    executeExpression = new ExpressionImpl(executeScript);
    evaluateExpression = new ExpressionImpl(evaluateScript);
  }

  @Override
  public boolean execute(Map<String, Object> parameters) {
    return (boolean) executeExpression.evaluate(parameters);
  }

  @Override
  public boolean evaluate(Map<String, Object> parameters) {
    return (boolean) evaluateExpression.evaluate(parameters);
  }
}
